import React from 'react';
import ReactDom from 'react-dom'
import { Spin,} from 'antd';
let loadDiv:any;
let root:any;


const Loading = ()=>{
  loadDiv = document.createElement("div");
  root = document.getElementById("root");
  ReactDom.render(<LoadingView />,loadDiv);
  root?.appendChild(loadDiv);
}

Loading.close = ()=>{
  root.removeChild(loadDiv);
}


const LoadingView = ()=>{
  return (
    <div
      style={{
        position:"fixed",
        top:0,
        left:0,
        width:"100%",
        height:"100%",
        display:"flex",
        justifyContent:"center",
        alignItems:"center",
        backgroundColor:"rgba(0,0,0,0.4)",
        zIndex:99999
      }}>
      <Spin tip="加载中" />
    </div>
  )
}



export default Loading;